{% extends 'goodies/main2.html' %}




{% block content %}
    <h2>Search</h2>

    <form action="/main/search" method="get" name="change">{% csrf_token %}

        {% for field in search_form %}
        
        <div class="fieldWrapper">
                      
            <div>{{ field.label }}
              {% if field.field.required %}
               <font color="red">*</font>:
              {% endif %}
                
                <font color="red">{{  field.errors|striptags }}</font>
             
    
                
            </div>

            {{ field }}
        </div>
        {% endfor %}
    <p><input type="submit" value="Найти" /></p>
    </form>



        <h3>Results</h3>

        {% for result in results %}
        <p>
            <a href="{{ result.object.get_absolute_url }}">{{ result.name }}</a>
            <br>{{ result.author }}
            <br>{{ result.year }}
            <br>{{ result.price }}
        </p>
        {% empty %}
        <p>No results found.</p>
        {% endfor %}

    {% if results.has_previous %}
        <a href="?page=1"   style="text-decoration:none;">
          <img src="/common/img/but/n_bb.gif" width="15" height="9" border="0" alt="" align="absmiddle">

      </a>

      <a href="?page={{ results.previous_page_number }}" style="text-decoration:none;">
          <img src="/common/img/but/n_b.gif" width="9" height="9" border="0" align="absmiddle" alt="">
      </a>

      {% else %}

      <img src="/common/img/but/n_bb_f.gif" width="15" height="9" border="0" alt="" align="absmiddle">
      <img src="/common/img/but/n_b_f.gif" width="9" height="9" border="0" align="absmiddle" alt="">
      {% endif %}


      {% for page in results.paginator.page_range %}
      {% if not results.number == page %}
      <a href="?page={{page}}">{{page}}</a>
      {% else %}
      {{page}}

      {% endif %}

      {% endfor %}




      {% if results.has_next %}
      <a href="?page={{ results.next_page_number }}"     style="text-decoration:none;">
          <img src="/common/img/but/n_n.gif" width="9" height="9" border="0" align="absmiddle" alt="">
      </a>
      <a href="?page={{ results.paginator.num_pages }}"  style="text-decoration:none;">
          <img src="/common/img/but/n_nn.gif" width="15" height="9" border="0" alt="" align="absmiddle">
      </a>
      {% else %}
      <img src="/common/img/but/n_n_f.gif" width="9" height="9" border="0" align="absmiddle" alt="">
      <img src="/common/img/but/n_nn_f.gif" width="15" height="9" border="0" alt="" align="absmiddle">

      {% endif %}


{% endblock %}